path = "/var/www/cgi-bin/r/modules/calc_special_efficient_portfolio.r"
print( path )
source( path )

#	正常系
test_calc_special_efficient_portfolio_000 <- function()
{
	print( "test case 000" )
	
	earning_rate_means <- c( 0.151, 0.125, 0.147, 0.0902, 0.1768 )
	earning_rate_covariances <- 
		matrix(
		c(  0.023,  0.0093,  0.0062,  0.0074, -0.0023,
				0,  0.0140,  0.0022,  0.0056,  0.0026,
				0,       0,  0.0180,  0.0078, -0.0027,
				0,       0,       0,  0.0340, -0.0056,
				0,       0,       0,       0,  0.0260 ),
		nrow = 5, ncol = 5 )
	earning_rate_covariances <- earning_rate_covariances + t( earning_rate_covariances )
	diag( earning_rate_covariances ) <- diag( earning_rate_covariances ) / 2
	riskless_earning_rate <- 0.10
	is_normalize = TRUE
	
	res <- calc_special_efficient_portfolio( 
		earning_rate_means, earning_rate_covariances, riskless_earning_rate, is_normalize )
	if ( is.null( res$error_message ) == FALSE ) {
		cat( "expected: is.null( res$error_message ), but res$error_message:", res$error_message, "\n" )
	}

	digit <- 9
	calc_error <- 0.00000001
	deltas = round( res$ratio, digit ) - round( c( 0.31719998, -0.06108573, 0.38650446, -0.11127402, 0.46865531 ), digit )
	deltas = abs( deltas )
	if ( length( deltas[ deltas > calc_error ] ) != 0 ) {
		cat( "expected: length( deltas[ deltas > calc_error ] ) == 0, deltas:", deltas, "\n" )
	}
#	print( res )
}


#run test
test_calc_special_efficient_portfolio_000()